<template>
	<view class="transferToApp">
		<view class="tit">
			申请提现手机号
		</view>
		<view class="name">
			<!-- 周海迪 -->
			<text>{{phone}}</text>
		</view>
		<view class="list">
			<view class="list-call">
				<input class="u-input" type="number" v-model="code" maxlength="6" placeholder="输入验证码" />
				<view class="code">
					<view class="line"></view>
					<view class="btns" @click="getCode">{{Tips}}
					</view>
				</view>
			</view>

		</view>
		<view class="tips">
			
		</view>

		<view class="btns1">
			<u-button shape="circle" type="error" class="button" @click="submit" :ripple="true"
				ripple-bg-color="#d7d8da">提交</u-button>
		</view>
		<u-verification-code endText="获取验证码" startText="获取验证码" seconds="60" ref="uCode" @change="codeChange">
		</u-verification-code>
	</view>
</template>

<script>
	export default {
		props: ['money', 'phone','type'],
		data() {
			return {
				code: '',
				// phone: '',
				Tips: '获取验证码',
				yzmStatus: false,
				codeTips: '',
			}
		},
		methods: {
			submit() {

				if (!this.code) {
					this.$u.toast('验证码不能为空！');
					return;
				}
				if (this.code.length!=6) {
					this.$u.toast('验证码为6位数！');
					return;
				}
				this.$u.api.commissionCash({
						captcha: this.code,
						cashAccountId:this.type,
						cashAmount:this.money
					})
					.then((res) => {
						console.log(res, 66666);

						if (res.code == 'ok') {
							this.$emit('refreshlist',true)

						} else {
							this.$emit('refreshlist',false)
							uni.showToast({
								icon:"none",
								duration:4000,
								title:res.msg
							})
						}
					});
			},
			codeChange(text) {
				this.Tips = text;
			},
			getCode() {
				
				if (this.$refs.uCode.canGetCode) {
					// 模拟向后端请求验证码
					uni.showLoading({
						title: '正在获取验证码',
						mask: true
					})
					console.log(33333);
					this.$u.api.captchaSend()
						
						.then((res) => {
							console.log(res, 777788899);
							if (res.code == 'ok') {
								uni.hideLoading();
								// 这里此提示会被this.start()方法中的提示覆盖
								this.$u.toast('验证码已发送');
								// 通知验证码组件内部开始倒计时
								this.$refs.uCode.start();

							} else {

								this.$u.toast(res.msg);
								// console.log("请求数据失败");
							}
						});

				} else {
					this.$u.toast('倒计时结束后再发送');
				}
			},
		}
	}
</script>


<style scoped lang="scss">
	.tips {
		margin-bottom: 38rpx;
		display: flex;

		image {
			width: 24rpx;
			height: 24rpx;
			margin-right: 8rpx;
		}

		.text {
			flex: 1;
			font-family: Alibaba PuHuiTi, Alibaba PuHuiTi;
			font-weight: 400;
			font-size: 20rpx;
			color: #A6A6A6;
			line-height: 23rpx;
		}
	}

	.btns1 {
		margin: 0 68rpx;
		background: #FA4A53;
		box-shadow: 0rpx 20rpx 24rpx 0rpx rgba(181, 36, 44, 0.2);
		border-radius: 40rpx 40rpx 40rpx 40rpx;
	}

	.transferToApp {
		padding: 50rpx 40rpx;

		/deep/ .u-close--top-right.data-v-17becaea {
			top: 50rpx !important;
		}

		.list {
			margin: 26rpx 0 30rpx;
		}

		.list-call {
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 24rpx;
			padding: 0 32rpx 0 30rpx;
			height: 80rpx;
			background: rgba(232, 230, 229, 0.12);
			border-radius: 44rpx 44rpx 44rpx 44rpx;
			border: 2rpx solid #F1F1F1;
		}

		.list-call .u-input {
			flex: 1;
			font-family: Alibaba PuHuiTi, Alibaba PuHuiTi;
			font-weight: 400;
			font-size: 24rpx;
			color: #0F1417;
			// line-height: 40rpx;
			text-align: justified;
			font-style: normal;
			text-transform: none;
		}

		.list-call .u-icon-right {
			// color: #aaaaaa;
			width: 48rpx;
			height: 48rpx;
		}


		.code {
			display: flex;
			align-items: center;

			.line {
				width: 2rpx;
				height: 28rpx;
				background: #E4E4E4;
			}

			.btns {
				font-family: Alibaba PuHuiTi, Alibaba PuHuiTi;
				font-weight: 400;
				font-size: 24rpx;
				color: #FA4A53;
				line-height: 40rpx;
				text-align: justified;
				font-style: normal;
				text-transform: none;
				padding-left: 14rpx;
			}


		}
		.tit {
			font-family: Alibaba PuHuiTi, Alibaba PuHuiTi;
			font-weight: 500;
			font-size: 32rpx;
			color: #FA4A53;
			line-height: 38rpx;
		}

		.name {
			margin-bottom: 24rpx;
			margin-top: 8rpx;
			font-family: Alibaba PuHuiTi, Alibaba PuHuiTi;
			font-weight: 500;
			font-size: 28rpx;
			color: #0F1417;
			line-height: 33rpx;
		}
	}
</style>
